package com.atguigu.yygh.hosp.controller.admin;

import com.atguigu.yygh.cmn.feignclient.DictFeignClient;
import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class AdminHospitalController {
    @Autowired
    private HospitalService hospitalService;


    @ApiOperation(value = "获取分页列表")
    @GetMapping("list/{page}/{limit}")
    public Result<Page<Hospital>> getHospitalPage(@PathVariable("page") Integer page,
                                                  @PathVariable("limit") Integer limit,
                                                  HospitalQueryVo hospitalQueryVo) {
        // 调用业务层分页查询
        Page<Hospital> hospitalPage = hospitalService.getHospitalPage(page, limit, hospitalQueryVo);
        // 返回数据结果
        return Result.ok(hospitalPage);
    }

    @ApiOperation(value = "更新医院上线状态")
    @PutMapping("updateStatus/{hospitalId}/{status}")
    public Result updateStatus(@PathVariable("hospitalId") String hospitalId,
                               @PathVariable("status") Integer status) {
        hospitalService.updateStatus(hospitalId, status);

        return Result.ok();
    }

    @ApiOperation(value = "查看医院详情")
    @GetMapping("/showHospDetail/{hospitalId}")
    public Result showHospDetail(@PathVariable("hospitalId") String hospitalId) {

        Map<String, Object> mapHosp = hospitalService.showHospDetailById(hospitalId);

        return Result.ok(mapHosp);
    }


}
